# Maintainer: Mateusz Mikuła <mati865@gmail.com>
# Contributor: Andrew Sun <adsun701@gmail.com>

_realname=geoip
_pkgname=geoip-api-c
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.6.12
pkgrel=1
pkgdesc="Non-DNS IP-to-country resolver C library & utils (mingw-w64)"
arch=('any')
url="https://www.maxmind.com/app/c"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-geoip2-database"
         "${MINGW_PACKAGE_PREFIX}-zlib")
makedepends=('autoconf'
             'libtool')
options=('!emptydirs')
source=(${_realname}-${pkgver}.tar.gz::https://github.com/maxmind/${_pkgname}/archive/v${pkgver}.tar.gz)
sha256sums=('99b119f8e21e94f1dfd6d49fbeed29a70df1544896e76cd456f25e397b07d476')

prepare(){
  cd ${_pkgname}-${pkgver}
  ./bootstrap
}

build() {
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  ../${_pkgname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared
  make
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
